import { GET_RECORDS,FREEZE_ACC_LOG } from "../constants/records";

const INITIAL_STATE = {
  page: 1,
  record_list: [],
  freeze_list: [],
  freeze_page: 1,
};

export default function records(state = INITIAL_STATE, action) {
  switch (action.type) {
    case GET_RECORDS:
      return {
        ...state,
        record_list:action.page === 1 ?[...action.record_list]:[...state.record_list,...action.record_list],
        page: action.page
      };
    case FREEZE_ACC_LOG:
      return {
        ...state,
        freeze_page: action.page,
        freeze_list:action.page === 1 ?[...action.freeze_list]:[...state.freeze_list,...action.freeze_list],
      }
    default:
      return { ...state };
  }
}
